home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / OBJCWIDG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-11  |  16.3 KB  |  564 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <OSBIND.H>
  9. #include <VDI.H>
  10. #include <memory.h>
  11. #include "XA_TYPES.H"
  12. #include "XA_DEFS.H"
  13. #include "XA_GLOBL.H"
  14. #include "KERNAL.H"
  15. #include "K_DEFS.H"
  16. #include "KERNAL.H"
  17. #include "GRAF_MOU.H"
  18. #include "C_WINDOW.H"
  19. #include "RECTLIST.H"
  20. #include "BOX3D.H"
  21. #include "OBJECTS.H"
  22. #include "MESSAGES.H"
  23. #include "SYS_MENU.H"
  24. #include "std_widg.h"
  25. #include "system.h"
  26. #include "resource.h"
  27. #include "desktop.h"
  28.  
  29. #ifndef THICKENED
  30. /* Lattice C should better use the TF_xxx-constants anyway... */
  31. #define THICKENED    0x01
  32. #define SHADED        0x02
  33. #define SKEWED        0x04
  34. #define UNDERLINED    0x08
  35. #define OUTLINE        0x10
  36. #define SHADOW        0x20
  37. #endif
  38.  
  39. /*
  40.     Menu Widget display
  41. */
  42. short display_menu_widget(XA_WINDOW *wind, XA_WIDGET *widg)
  43. {
  44.     short x,y;
  45.     XA_WIDGET_TREE *w_otree=(XA_WIDGET_TREE*)widg->stuff;
  46.     XA_CLIENT *client;
  47.     OBJECT *root;
  48.     short pxy[4];
  49.     short title,this_t=-1,sel_t=-1,sel_t_menu;
  50.     short menu_x,menu_y;
  51.     short menu_text,mty;
  52.     short mx,my,mb;
  53.  
  54.     DIAGS(("display_menu_widget(wind=%d)\n",wind->handle));
  55.  
  56.     rp_2_ap(wind, widg, &x, &y);    /* Convert relative coords and window location to absolute screen location */
  57.  
  58.     DIAGS(("1\n"));
  59.     
  60.     root=w_otree->tree;
  61.     DIAGS(("w_otree=%lx,root=%lx\n",w_otree,root));
  62.  
  63.     root->ob_x=x; root->ob_y=y;
  64.     DIAGS(("3\n"));
  65.  
  66.     vst_color(V_handle, BLACK);
  67.     DIAGS(("4\n"));
  68.  
  69.     pxy[0]=x; pxy[1]=y;
  70.     pxy[2]=wind->w+wind->x-x; pxy[3]=y+widg->h;
  71.     vsf_color(V_handle, display.dial_colours.bg_col);
  72.     v_bar(V_handle,pxy);
  73.     DIAGS(("5\n"));
  74.         
  75.     title=root[root[root[0].ob_head].ob_head].ob_head;
  76.     DIAGS(("6\n"));
  77.  
  78.     vq_mouse(V_handle, &mb, &mx, &my);
  79.     DIAGS(("7\n"));
  80.     
  81.     vsf_color(V_handle, BLACK);
  82.     DIAGS(("8\n"));
  83.     
  84.     while(title!=root[root[0].ob_head].ob_head)        /* Display titles */
  85.     {
  86.         this_t++;
  87.         if (root[title].ob_state&SELECTED)
  88.         {
  89.             sel_t=this_t; 
  90.             menu_x=root[title].ob_x+x-2; menu_y=y;
  91.             vst_color(V_handle, WHITE);
  92.             pxy[0]=menu_x+2; pxy[1]=menu_y;
  93.             pxy[2]=pxy[0]+root[title].ob_width+4;
  94.             pxy[3]=pxy[1]+widg->h;
  95.             v_bar(V_handle,pxy);
  96.             v_gtext(V_handle, root[title].ob_x+x, y+2, (char*)root[title].ob_spec);
  97.             vst_color(V_handle, BLACK);
  98.         }else{
  99.             v_gtext(V_handle, root[title].ob_x+x, y+2, (char*)root[title].ob_spec);
  100.         }
  101.         title=root[title].ob_next;
  102.     }
  103.     DIAGS(("9\n"));
  104.     
  105.     if ((widg->stat==XAW_SELECTED)&&(sel_t!=-1))    /* If a menu is selected, display the actual menu */
  106.     {
  107.         sel_t_menu=root[root[0].ob_tail].ob_head;
  108.         for(title=0; (title!=sel_t); title++)
  109.             sel_t_menu=root[sel_t_menu].ob_next;
  110.             
  111.         if (sel_t!=0)
  112.         {
  113.             pxy[1]=y+widg->h; 
  114.             pxy[2]=pxy[0]+root[sel_t_menu].ob_width;
  115.             pxy[3]=pxy[1]+root[sel_t_menu].ob_height;
  116.             XA_3D_rect(menu_x,menu_y+widg->h+2,root[sel_t_menu].ob_width+10,root[sel_t_menu].ob_height+4,2,1);
  117.  
  118.             vsf_color(V_handle,BLACK);
  119.  
  120.             mty=menu_y+widg->h+5;
  121.         
  122.             for(menu_text=root[sel_t_menu].ob_head; menu_text!=sel_t_menu; menu_text=root[menu_text].ob_next)
  123.             {
  124.                 if (root[menu_text].ob_state&DISABLED)            /* Disabled item? */
  125.                 {
  126.                     vst_effects(V_handle, SHADED);
  127.                 }else{
  128.                     if (root[menu_text].ob_state&SELECTED)        /* Selected menu item? */
  129.                     {
  130.                         vst_color(V_handle, WHITE);
  131.                         pxy[0]=menu_x+5; pxy[1]=mty;
  132.                         pxy[2]=pxy[0]+root[sel_t_menu].ob_width+1;
  133.                         pxy[3]=pxy[1]+display.c_max_h;
  134.                         v_bar(V_handle,pxy);
  135.                     }
  136.                 }
  137.                 v_gtext(V_handle, menu_x+5, mty, (char*)root[menu_text].ob_spec);
  138.  
  139.                 if (root[menu_text].ob_state&CHECKED)    /* Display a check mark if needed */
  140.                     v_gtext(V_handle, menu_x+5, mty, "");
  141.             
  142.                 vst_effects(V_handle, 0);
  143.                 vst_color(V_handle,BLACK);
  144.                 mty+=display.c_max_h;
  145.             }
  146.         }else{
  147.             pxy[1]=y+widg->h; 
  148.             pxy[2]=pxy[0]+root[sel_t_menu].ob_width;
  149.             pxy[3]=pxy[1]+root[sel_t_menu].ob_height;
  150.             XA_3D_rect(menu_x,menu_y+widg->h+2,root[sel_t_menu].ob_width+10,root[sel_t_menu].ob_height+4,2,1);
  151.  
  152.             vsf_color(V_handle,BLACK);
  153.  
  154.             mty=menu_y+widg->h+5;
  155.         
  156.             menu_text=root[sel_t_menu].ob_head;
  157.  
  158.             if (root[menu_text].ob_state&DISABLED)            /* Disabled item? */
  159.             {
  160.                 vst_effects(V_handle, SHADED);
  161.             }else{
  162.                 if (root[menu_text].ob_state&SELECTED)        /* Selected menu item? */
  163.                 {
  164.                     vst_color(V_handle, WHITE);
  165.                     pxy[0]=menu_x+5; pxy[1]=mty;
  166.                     pxy[2]=pxy[0]+root[sel_t_menu].ob_width+1;
  167.                     pxy[3]=pxy[1]+display.c_max_h;
  168.                     v_bar(V_handle,pxy);
  169.                 }
  170.             }
  171.             v_gtext(V_handle, menu_x+5, mty, (char*)root[menu_text].ob_spec);
  172.             
  173.             mty+=display.c_max_h;
  174.             pxy[0]=menu_x+4; pxy[1]=pxy[3]=mty;
  175.             pxy[2]=pxy[0]+root[sel_t_menu].ob_width+1;
  176.             v_pline(V_handle,2,pxy);
  177.             
  178.             mty+=3;
  179.             
  180.             for(client=FirstClient(); client!=NULL; client=NextClient(client))
  181.             {
  182.                 if (client->clnt_pipe_rd)
  183.                 {
  184.                     if (((mx>menu_x)&&(mx<menu_x+root[sel_t_menu].ob_width))&&((my>mty)&&(my<mty+display.c_max_h)))
  185.                     {
  186.                         vst_color(V_handle, WHITE);
  187.                         vsf_color(V_handle,BLACK);
  188.                     }else{
  189.                         vst_color(V_handle, BLACK);
  190.                         vsf_color(V_handle, display.dial_colours.bg_col);
  191.                     }
  192.                     pxy[0]=menu_x+5; pxy[1]=mty;
  193.                     pxy[2]=pxy[0]+root[sel_t_menu].ob_width+1;
  194.                     pxy[3]=pxy[1]+display.c_max_h;
  195.                     v_bar(V_handle,pxy);
  196.                     
  197.                     v_gtext(V_handle, menu_x+5, mty, client->name);
  198.  
  199.                     if (((XA_WIDGET_TREE*)root_window->widgets[XAW_MENU].stuff)->owner==Client2Pid(client))
  200.                     {
  201.                         v_gtext(V_handle, menu_x+5, mty, "");
  202.                     }else{
  203.                         if (client->client_type==XA_CT_ACC)
  204.                         {
  205.                             v_gtext(V_handle, menu_x+5, mty, "°");
  206.                         }
  207.                     }
  208.                     
  209.                     vst_color(V_handle,BLACK);
  210.                     mty+=display.c_max_h;
  211.                 }
  212.             }
  213.         }
  214.     }
  215.     DIAGS(("A\n"));
  216.     return TRUE;
  217. }
  218.  
  219. /*
  220.     Generic Object Tree Widget display
  221. */
  222. short display_object_widget(XA_WINDOW *wind, XA_WIDGET *widg)
  223. {
  224.     short x,y;
  225.     XA_WIDGET_TREE *w_otree=(XA_WIDGET_TREE*)widg->stuff;
  226.     OBJECT *root;
  227.  
  228.     DIAGS(("display_object_widget(wind=%d)\n",wind->handle));
  229.  
  230.     rp_2_ap(wind, widg, &x, &y);    /* Convert relative coords and window location to absolute screen location */
  231.     
  232.     root=w_otree->tree;
  233.  
  234.     root->ob_x=x; root->ob_y=y;
  235.     draw_object_tree(root, 0, 100);
  236.  
  237.     return TRUE;
  238. }
  239.  
  240. /*
  241.     Really should get the multi-thread support in here....doesn't work at the
  242.     moment though...
  243. */
  244. const char *empty_title="";
  245.  
  246. short init_moose(void);
  247.  
  248. short click_menu_widget(XA_WINDOW *wind, XA_WIDGET *widg)
  249. {
  250.     XA_WIDGET_TREE *w_otree=(XA_WIDGET_TREE*)widg->stuff;
  251.     OBJECT *root;
  252.     XA_CLIENT *client;
  253.     MOOSE_DCLICK_COM moose_enable;
  254.     short clicked_title,selected_menu=-1,x,y,f,n;
  255.     short point_at_menu=-1,t,pxy[8],point_at_title,menu_mode;
  256.     short mx,my,mb,omx,omy,exit_mb;
  257.     short menu_x,menu_y,old_menu_y=0;
  258.     MFDB Mscreen;
  259.     MFDB Mpreserve;
  260.  
  261.     rp_2_ap(wind, widg, &x, &y);    /* Convert relative coords and window location to absolute screen location */
  262.     root=w_otree->tree;
  263.     root->ob_x=x; root->ob_y=y;
  264.  
  265.     vq_mouse(V_handle,&mb,&mx,&my);
  266.     if (mb)                            /* Exit conditions for the menu - mouse down/mouse up */
  267.         exit_mb=0;
  268.     else
  269.         exit_mb=1;
  270.  
  271.     if (wind==root_window)        /* Tear off menu bar support (root menu only) */
  272.     {
  273.         vq_key_s(V_handle,&t);
  274.         if (t&4)
  275.         {
  276.             XA_WINDOW *new_menu_window;
  277.             short w,max_w;
  278.             
  279.             max_w=0;
  280.             for(f=root[root[root[0].ob_head].ob_head].ob_head; f!=root[root[0].ob_head].ob_head; f=root[f].ob_next)
  281.             {
  282.                 w=root[f].ob_x+root[f].ob_width;
  283.                 if (w>max_w)
  284.                     max_w=w;
  285.             }
  286.             new_menu_window=create_window(((XA_WIDGET_TREE*)root_window->widgets[XAW_MENU].stuff)->owner, CLOSE|NAME|MOVE|NO_MESSAGES|NO_WORK, x,y+widg->h, max_w+34, widg->h+8);
  287.             new_menu_window->is_open=TRUE;
  288.             new_menu_window->widgets[XAW_TITLE].stuff=(void*)empty_title;
  289.  
  290.             set_menu_widget(new_menu_window, widg->loc, (OBJECT*)((XA_WIDGET_TREE*)root_window->widgets[XAW_MENU].stuff)->tree);
  291.             new_menu_window->widgets[XAW_TITLE].w=new_menu_window->widgets[XAW_CLOSE].w;
  292.             new_menu_window->widgets[XAW_TITLE].loc.x=new_menu_window->widgets[XAW_CLOSE].loc.x+new_menu_window->widgets[XAW_CLOSE].w+1;
  293.             new_menu_window->widgets[XAW_MENU].loc.x=new_menu_window->widgets[XAW_TITLE].loc.x+new_menu_window->widgets[XAW_TITLE].w;
  294.             new_menu_window->widgets[XAW_MENU].w=max_w;
  295.             new_menu_window->widgets[XAW_MENU].loc.y=2;
  296.             ((XA_WIDGET_TREE*)new_menu_window->widgets[XAW_MENU].stuff)->owner=((XA_WIDGET_TREE*)root_window->widgets[XAW_MENU].stuff)->owner;
  297.             pull_wind_to_top(new_menu_window);
  298.             v_hide_c(V_handle);
  299.             display_non_topped_window(new_menu_window,NULL);
  300.             v_show_c(V_handle,1);
  301.  
  302.             return FALSE;
  303.         }
  304.     }
  305.     
  306.     omx=x+widg->click_x; omy=y+widg->click_y;
  307.     clicked_title=find_object(root, root[root[0].ob_head].ob_head, 2, omx, omy);
  308.  
  309.     if ((clicked_title>-1)&&(root[clicked_title].ob_type==G_TITLE))
  310.     {
  311.         widg->stat=XAW_SELECTED; 
  312.  
  313.         do 
  314.         {
  315.             menu_mode=1;
  316.             
  317.             n=root[root[0].ob_tail].ob_head;
  318.             for(f=root[root[root[0].ob_head].ob_head].ob_head; f!=root[root[0].ob_head].ob_head; f=root[f].ob_next)
  319.             {
  320.                 if (f==clicked_title)
  321.                 {
  322.                     selected_menu=n;
  323.                 }else{
  324.                     root[f].ob_state&=~SELECTED;
  325.                 }
  326.                 n=root[n].ob_next;
  327.             }
  328.             root[clicked_title].ob_state|=SELECTED;
  329.             
  330.             menu_x=root[clicked_title].ob_x+x-2;
  331.             menu_y=y+widg->h;
  332.             
  333.             Mpreserve.fd_w=root[selected_menu].ob_width+20;
  334.             Mpreserve.fd_h=root[selected_menu].ob_height+20;
  335.             Mpreserve.fd_wdwidth=(Mpreserve.fd_w+15)>>4;
  336.             Mpreserve.fd_nplanes=display.planes;
  337.             Mpreserve.fd_stand=0;
  338.     /* Always remember that the MFDB-members are short, and short * short = short,
  339.      * which will be converted into a long for the malloc call. Usually, it will
  340.      * be converted preserving the sign, so that 0x8000 becomes 0xffff8000!
  341.      * Also consider that short * short may easily no longer fit into a short.
  342.      */
  343.             Mpreserve.fd_addr=(void*)malloc((long)Mpreserve.fd_h * (long)Mpreserve.fd_wdwidth * 2L * (long)display.planes);
  344.     
  345.             Mscreen.fd_addr=NULL;
  346.     
  347.             if (!Mpreserve.fd_addr)
  348.             {
  349.                 root[clicked_title].ob_state&=~SELECTED;    /* Deselect the title */
  350.                 DIAGS(("ERROR: Cann't allocate memory for menu background\n"));
  351.                 return TRUE;
  352.             }
  353.     
  354.             clear_clip();                /* Menu's are always on top...so don't clip */
  355.     
  356.             pxy[0]=menu_x; pxy[1]=menu_y;                    /* Preserve background */
  357.             pxy[2]=menu_x+Mpreserve.fd_w-1; pxy[3]=menu_y+Mpreserve.fd_h-4;
  358.             pxy[4]=0; pxy[5]=0;
  359.             pxy[6]=Mpreserve.fd_w-1; pxy[7]=Mpreserve.fd_h-4;
  360.     
  361.             v_hide_c(V_handle);
  362.             vro_cpyfm(V_handle, S_ONLY, pxy, &Mscreen, &Mpreserve);
  363.     
  364.             display_menu_widget(wind, widg);
  365.             v_show_c(V_handle, 1);
  366.             
  367.             moose_enable.dclick_prefix=0x4d44;    /* Disable moose to avoid click fall through */
  368.             moose_enable.dclick_time=0;
  369.             Fwrite(MOUSE_dev,4L,&moose_enable);
  370.     
  371.     /* Do a point-at-and-click menu selection */
  372.             do{
  373.                 vq_mouse(V_handle,&mb,&mx,&my);
  374.                 
  375.                 if ((mx!=omx)||(my!=omy))
  376.                 {
  377.                     omx=mx; omy=my;
  378.                     menu_y=y+widg->h+5;
  379.                     
  380.                     t=-1;
  381.     
  382.                     if ((mx>menu_x)&&(mx<menu_x+root[selected_menu].ob_width))    /* Find pointed at menu entry */
  383.                     {
  384.                         for(f=root[selected_menu].ob_head; (f!=selected_menu)&&(t==-1); f=root[f].ob_next)
  385.                         {
  386.                             if ((my>menu_y)&&(my<menu_y+display.c_max_h))
  387.                             {
  388.                                 t=f;
  389.                             }else{
  390.                                 menu_y+=display.c_max_h;
  391.                             }
  392.                         }
  393.                     }
  394.     
  395.                     if (t!=point_at_menu)
  396.                     {
  397.                         if (point_at_menu!=-1)        /* De-select current selection (if any) */
  398.                         {
  399.                             root[point_at_menu].ob_state&=~SELECTED;
  400.                             set_clip(menu_x-5, old_menu_y-5,
  401.                                     root[selected_menu].ob_width+10, display.c_max_h+10);
  402.                             v_hide_c(V_handle);
  403.                             display_menu_widget(wind, widg);
  404.                             v_show_c(V_handle, 1);
  405.                         }
  406.                     
  407.                         if (t!=-1)                /* Something selected at the moment? */
  408.                         {                        /* Highlight current selection */
  409.                             root[t].ob_state|=SELECTED;
  410.                             set_clip(menu_x-5,menu_y-5,
  411.                                     root[selected_menu].ob_width+10,display.c_max_h+10);
  412.                             v_hide_c(V_handle);
  413.                             display_menu_widget(wind, widg);
  414.                             v_show_c(V_handle, 1);
  415.                             old_menu_y=menu_y;
  416.                         }
  417.  
  418.                         clear_clip();
  419.                         point_at_menu=t;
  420.                     }
  421.                     
  422.                     if (t==-1)        /* not pointing at a menu item - check for a new title */
  423.                     {
  424.                         point_at_title=find_object(root, root[root[0].ob_head].ob_head, 2, omx, omy);
  425.                         
  426.                         if (((point_at_title>-1)
  427.                             &&(point_at_title!=clicked_title))
  428.                             &&(root[point_at_title].ob_type==G_TITLE))
  429.                         {
  430.                             menu_mode=2;
  431.                         }
  432.                     }
  433.  
  434.                 }
  435.             }while((mb!=exit_mb)&&(menu_mode==1));
  436.  
  437.             moose_enable.dclick_prefix=0x4d44;            /* Re-enable moose */
  438.             moose_enable.dclick_time=50;
  439.             Fwrite(MOUSE_dev,4L,&moose_enable);
  440.     
  441.             root[clicked_title].ob_state&=~SELECTED;    /* Deselect the title */
  442.     
  443.             pxy[4]=pxy[0]; pxy[5]=pxy[1];                /* Restore background */
  444.             pxy[6]=pxy[2]; pxy[7]=pxy[3];
  445.             pxy[0]=0; pxy[1]=0;
  446.             pxy[2]=Mpreserve.fd_w-1; pxy[3]=Mpreserve.fd_h-4;
  447.             v_hide_c(V_handle);
  448.             vro_cpyfm(V_handle, S_ONLY, pxy, &Mpreserve, &Mscreen);
  449.             v_show_c(V_handle, 1);
  450.             
  451.             free(Mpreserve.fd_addr);
  452.                 
  453.             clear_clip();
  454.             display_menu_widget(wind, widg);
  455.  
  456.             if (mb==exit_mb)
  457.             {
  458.                 menu_mode=0;
  459.             }else{
  460.                 clicked_title=point_at_title;
  461.             }
  462.  
  463.         } while(menu_mode);
  464.         
  465.         if ((clicked_title!=root[root[root[0].ob_head].ob_head].ob_head)||(point_at_menu==root[selected_menu].ob_head))
  466.         {
  467.         
  468.             if (point_at_menu!=-1)    /* Exitting with a selection - send it */
  469.             {
  470.                 DIAGS(("Menu selected\n"));
  471.                 root[point_at_menu].ob_state&=~SELECTED;    /* Deselect the menu entry */
  472.                 if (w_otree->owner!=AESpid)        /* If it's a client program menu, send it a little message to say hi.... */
  473.                 {
  474.                     DIAGS(("Calling send_app_message()\n"));
  475.                     DIAGS(("app=%d,title=%d,point_at=%d\n",w_otree->owner,clicked_title, point_at_menu));
  476.                     DIAGS(("root=%ld, sel_menu=%d\n",root, selected_menu));
  477.                                 /* Note the AES4.0 extended message format...... */
  478.                     send_app_message(w_otree->owner, MN_SELECTED, AESpid, clicked_title, point_at_menu, (short)((long)root>>16), (short)((long)root&0xffff), selected_menu);
  479.                 }else{                            /* Otherwise, process system menu clicks */
  480.                     DIAGS(("do_system_menu()\n"));
  481.                     do_system_menu(clicked_title, point_at_menu);
  482.                 }
  483.             }
  484.             
  485.         }else{
  486.         
  487.             DIAGS(("click on desk menu\n"));
  488.             menu_y=y+widg->h+9+display.c_max_h; n=1;
  489.             for(client=FirstClient(); client; client=NextClient(client))
  490.             {
  491.                 if (client->clnt_pipe_rd)
  492.                 {
  493.                     DIAGS(("candidate:%s\n",client->name));
  494.                     if ((my>menu_y)&&(my<menu_y+display.c_max_h))
  495.                     {
  496.                         DIAGS(("match\n"));
  497.                         break;
  498.                     }
  499.                     menu_y+=display.c_max_h;
  500.                 }
  501.             }
  502.             
  503.             if (client)
  504.             {
  505.                 DIAGS(("got client pid=%d\n",Client2Pid(client)));
  506.                 switch (client->client_type)
  507.                 {
  508.                     case XA_CT_ACC:        /* Accessory - send AC_OPEN */
  509.                         DIAGS(("is an accessory\n"));
  510.                         send_app_message(Client2Pid(client), AC_OPEN, AESpid, 0, 0, 0, 0, 0);
  511.                         break;
  512.             
  513.                     case XA_CT_APP:        /* Application, swap topped app */
  514.                         DIAGS(("is a real GEM client\n"));
  515.                         {
  516.                             XA_WIDGET_TREE *menu_bar=(XA_WIDGET_TREE*)(root_window->widgets[XAW_MENU].stuff);
  517.                         
  518.                             if (client->std_menu!=menu_bar->tree)    /* Different menu? */
  519.                             {
  520.                                 GRECT clip;
  521.             
  522.                                 menu_bar->tree=client->std_menu;
  523.                     
  524.                                 if (client->std_menu==clients[AESpid].std_menu)
  525.                                     menu_bar->owner=AESpid;        /* Apps with no menu get the default menu, and that's owned by the AES */
  526.                                 else
  527.                                     menu_bar->owner=Client2Pid(client);    /* Apps with menu's own their own menu */
  528.                 
  529.                                 rp_2_ap(root_window, root_window->widgets+XAW_MENU, &clip.g_x, &clip.g_y);
  530.     
  531.                                 clip.g_w=root_window->widgets[XAW_MENU].w;
  532.                                 clip.g_h=root_window->widgets[XAW_MENU].h;
  533.     
  534.                                 v_hide_c(V_handle);
  535.                                 display_non_topped_window(root_window,&clip);
  536.                                 v_show_c(V_handle,1);
  537.                             }else{                                            /* Same menu, just a different owner... */
  538.                                 menu_bar->owner=Client2Pid(client);
  539.                             }
  540.             
  541.                             if ((client->desktop)                    /* Change desktops? */
  542.                                 &&((client->desktop!=desktop)&&(client->desktop!=ResourceTree(system_resources,DEF_DESKTOP))))
  543.                             {
  544.                                 set_desktop(client->desktop);
  545.                                 root_window->owner=Client2Pid(client);
  546.     
  547.                                 v_hide_c(V_handle);
  548.                                 display_non_topped_window(root_window,NULL);
  549.                                 v_show_c(V_handle,1);
  550.                             }
  551.                         }
  552.                         break;
  553.                 }
  554.             }
  555.         }
  556.         
  557.         widg->stat=XAW_PLAIN;
  558.  
  559.     }
  560.  
  561.     return FALSE;        /* Return false so we don't re-display the widget */
  562. }
  563.  
  564.